<template>
  <div class="home">
    <el-container>
      <el-header>
        <el-menu :default-active="defaultIndex" class="el-menu-demo" mode="horizontal" @select="handleSelect">
          <el-menu-item index="0">
            <i class="el-icon-menu"></i>
            <span>商品</span>
          </el-menu-item>
          <el-menu-item index="1">
            <i class="el-icon-document"></i>
            <span>订单</span>
          </el-menu-item>
          <el-menu-item index="2">
            <i class="el-icon-setting"></i>
            <span>我的</span>
          </el-menu-item>
        </el-menu>
      </el-header>
      <el-container>
        <el-aside width="200px">
          <el-menu :default-active="defaultIndex" class="el-menu-vertical-demo" @select="asideSelect">
            <el-menu-item v-for="(item,i) in aside" :index="i.toString()">{{item}}</el-menu-item>
          </el-menu>
        </el-aside>

        <el-main>
          <router-view/>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
// @ is an alias to /src


export default {
  name: 'Home',
  data(){
    return{
      defaultIndex:"0",
      aside:[],
      goods:['商品列表','上架商品','下架商品'],
      order:['订单列表'],
      mime:['售后服务','店面设计','密码修改'],
      location:"0"
    }
  },
  methods:{
    handleSelect(key, keyPath){
      if(key==0){
        this.aside = this.goods;
        this.location = key;
      } else if(key==1){
        this.aside = this.order;
        this.location = key;
      }else if(key==2){
        this.aside = this.mime;
        this.location = key
      }
    },
    asideSelect(key,keyPath){
      if(this.location == 0){
        if(key==0){
          this.$router.push('/goodList');
        }else if(key==1){
          this.$router.push('/goodAdd');
        }else if(key==2){
          this.$router.push('goodReduce');
        }
      }
      else if(this.location == 1){
        if(key==0){
          this.$router.push('/orderList')
        }
      }
      else if(this.location == 2){
        if(key==0){
          this.$router.push('/service');
        }else if(key==1){
          this.$router.push('/storeDesign');
        }else if(key==2){
          this.$router.push('/modifyPwd');
        }
      }
    }
  },
  mounted() {
    this.aside = this.goods;
    console.log(this.$store.state.userId)
  }
}
</script>

<style>

</style>
